using UnityEngine;
// [Assembly-CSharp.dll].ParticleEffectsLibrary
public class ParticleEffectsLibrary : MonoBehaviour
{
    // Fields
    public static ParticleEffectsLibrary GlobalAccess;
    public int TotalEffects;
    public int CurrentParticleEffectIndex;
    public int CurrentParticleEffectNum;
    public UnityEngine.Vector3[] ParticleEffectSpawnOffsets;
    public float[] ParticleEffectLifetimes;
    public UnityEngine.GameObject[] ParticleEffectPrefabs;
    private string effectNameString;
    private System.Collections.Generic.List<UnityEngine.Transform> currentActivePEList;
    private UnityEngine.Vector3 spawnPosition;
    
    // Methods
    private void Awake()
    {
        Unknown val_6;
        var val_7;
        var val_8;
        var val_9;
        mem2[0] = this;
        System.Collections.Generic.List<System.Object> val_1 = 536877615;
        val_1 = new System.Collections.Generic.List<System.Object>();
        this.currentActivePEList = val_1;
        val_6 = this.ParticleEffectPrefabs;
        this.CurrentParticleEffectNum = 1;
        mem[1152921504930430424] = this.ParticleEffectPrefabs.Length;
        if(this.ParticleEffectPrefabs.Length != this.ParticleEffectSpawnOffsets.Length)
        {
                UnityEngine.Debug.LogError(message:  -1610604551);
            val_6 = this.ParticleEffectPrefabs;
        }
        
        if(mem[1152921504930430424] != this.ParticleEffectPrefabs.Length)
        {
                UnityEngine.Debug.LogError(message:  -1610604553);
        }
        
        if(this.CurrentParticleEffectIndex >= this.ParticleEffectPrefabs.Length)
        {
                throw new NullReferenceException();
        }
        
        if(mem[536881491] == 0)
        {
                throw new NullReferenceException();
        }
        
        mem[536881499] = this.ParticleEffectPrefabs[this.CurrentParticleEffectIndex].name;
        if((-1610612535) != 0)
        {
                val_7 = -1610612535;
        }
        else
        {
                val_7 = 0;
        }
        
        if(mem[536881491] <= 1)
        {
                throw new NullReferenceException();
        }
        
        mem[536881507] = val_7;
        if(mem[536881491] <= 2)
        {
                throw new NullReferenceException();
        }
        
        mem[536881515] = this.CurrentParticleEffectNum.ToString();
        if((-1610612365) != 0)
        {
                val_8 = -1610612365;
        }
        else
        {
                val_8 = 0;
        }
        
        if(mem[536881491] <= 3)
        {
                throw new NullReferenceException();
        }
        
        mem[536881523] = val_8;
        if(mem[536881491] <= 4)
        {
                throw new NullReferenceException();
        }
        
        mem[536881531] = mem[1152921504930430424].ToString();
        if((-1610611783) != 0)
        {
                val_9 = -1610611783;
        }
        else
        {
                val_9 = 0;
        }
        
        if(mem[536881491] <= 5)
        {
                throw new NullReferenceException();
        }
        
        mem[536881539] = val_9;
        this.effectNameString = +536881467;
        throw new NullReferenceException();
    }
    private void Start()
    {
    
    }
    public string GetCurrentPENameString()
    {
        var val_4;
        var val_5;
        var val_6;
        if(this.CurrentParticleEffectIndex >= this.ParticleEffectPrefabs.Length)
        {
                throw new ArrayTypeMismatchException();
        }
        
        if(mem[536881491] == 0)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881499] = this.ParticleEffectPrefabs[this.CurrentParticleEffectIndex].name;
        if((-1610612535) != 0)
        {
                val_4 = -1610612535;
        }
        else
        {
                val_4 = 0;
        }
        
        if(mem[536881491] <= 1)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881507] = val_4;
        if(mem[536881491] <= 2)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881515] = this.CurrentParticleEffectNum.ToString();
        if((-1610612365) != 0)
        {
                val_5 = -1610612365;
        }
        else
        {
                val_5 = 0;
        }
        
        if(mem[536881491] <= 3)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881523] = val_5;
        if(mem[536881491] <= 4)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881531] = this.TotalEffects.ToString();
        if((-1610611783) != 0)
        {
                val_6 = -1610611783;
        }
        else
        {
                val_6 = 0;
        }
        
        if(mem[536881491] <= 5)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881539] = val_6;
        return +536881467;
    }
    public void PreviousParticleEffect()
    {
        int val_10;
        var val_11;
        var val_12;
        var val_13;
        if(this.CurrentParticleEffectIndex >= this.ParticleEffectLifetimes.Length)
        {
                throw new ArrayTypeMismatchException();
        }
        
        if((this.ParticleEffectLifetimes[this.CurrentParticleEffectIndex] == 0f) && (this.ParticleEffectLifetimes[this.CurrentParticleEffectIndex] >= 1))
        {
                var val_11 = 0;
            do
        {
            if(this.currentActivePEList.Item[0] != 0)
        {
                UnityEngine.Object.Destroy(obj:  this.currentActivePEList.Item[0].gameObject);
        }
        
            val_11 = val_11 + 1;
        }
        while(val_11 < (-1073676297));
        
            mem2[0] = 0;
            mem2[0] = 536890206;
            if((-1073676297) >= 1)
        {
                System.Array.Clear(array:  this.currentActivePEList, index:  0, length:  -1073676297);
        }
        
        }
        
        val_10 = this.CurrentParticleEffectIndex;
        if(val_10 <= 0)
        {
                val_10 = this.TotalEffects;
        }
        
        this.CurrentParticleEffectNum = val_10;
        this.CurrentParticleEffectIndex = val_10 - 1;
        if(this.CurrentParticleEffectIndex >= this.ParticleEffectPrefabs.Length)
        {
                throw new ArrayTypeMismatchException();
        }
        
        if(mem[536881491] == 0)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881499] = this.ParticleEffectPrefabs[this.CurrentParticleEffectIndex].name;
        if((-1610612535) != 0)
        {
                val_11 = -1610612535;
        }
        else
        {
                val_11 = 0;
        }
        
        if(mem[536881491] <= 1)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881507] = val_11;
        if(mem[536881491] <= 2)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881515] = this.CurrentParticleEffectNum.ToString();
        if((-1610612365) != 0)
        {
                val_12 = -1610612365;
        }
        else
        {
                val_12 = 0;
        }
        
        if(mem[536881491] <= 3)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881523] = val_12;
        if(mem[536881491] <= 4)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881531] = this.TotalEffects.ToString();
        if((-1610611783) != 0)
        {
                val_13 = -1610611783;
        }
        else
        {
                val_13 = 0;
        }
        
        if(mem[536881491] <= 5)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881539] = val_13;
        this.effectNameString = +536881467;
        throw new NullReferenceException();
    }
    public void NextParticleEffect()
    {
        var val_10;
        var val_11;
        var val_12;
        if(this.CurrentParticleEffectIndex >= this.ParticleEffectLifetimes.Length)
        {
                throw new ArrayTypeMismatchException();
        }
        
        if((this.ParticleEffectLifetimes[this.CurrentParticleEffectIndex] == 0f) && (this.ParticleEffectLifetimes[this.CurrentParticleEffectIndex] >= 1))
        {
                var val_11 = 0;
            do
        {
            if(this.currentActivePEList.Item[0] != 0)
        {
                UnityEngine.Object.Destroy(obj:  this.currentActivePEList.Item[0].gameObject);
        }
        
            val_11 = val_11 + 1;
        }
        while(val_11 < (-1073676297));
        
            mem2[0] = 0;
            mem2[0] = 536890206;
            if((-1073676297) >= 1)
        {
                System.Array.Clear(array:  this.currentActivePEList, index:  0, length:  -1073676297);
        }
        
        }
        
        int val_12 = this.TotalEffects;
        val_12 = val_12 - 1;
        int val_5 = (this.CurrentParticleEffectIndex >= val_12) ? 0 : (this.CurrentParticleEffectIndex + 1);
        this.CurrentParticleEffectIndex = val_5;
        val_5 = val_5 + 1;
        this.CurrentParticleEffectNum = val_5;
        if(this.CurrentParticleEffectIndex >= this.ParticleEffectPrefabs.Length)
        {
                throw new ArrayTypeMismatchException();
        }
        
        if(mem[536881491] == 0)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881499] = this.ParticleEffectPrefabs[this.CurrentParticleEffectIndex].name;
        if((-1610612535) != 0)
        {
                val_10 = -1610612535;
        }
        else
        {
                val_10 = 0;
        }
        
        if(mem[536881491] <= 1)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881507] = val_10;
        if(mem[536881491] <= 2)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881515] = this.CurrentParticleEffectNum.ToString();
        if((-1610612365) != 0)
        {
                val_11 = -1610612365;
        }
        else
        {
                val_11 = 0;
        }
        
        if(mem[536881491] <= 3)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881523] = val_11;
        if(mem[536881491] <= 4)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881531] = val_12.ToString();
        if((-1610611783) != 0)
        {
                val_12 = -1610611783;
        }
        else
        {
                val_12 = 0;
        }
        
        if(mem[536881491] <= 5)
        {
                throw new ArrayTypeMismatchException();
        }
        
        mem[536881539] = val_12;
        this.effectNameString = +536881467;
        throw new NullReferenceException();
    }
    public void SpawnParticleEffect(UnityEngine.Vector3 positionInWorldToSpawn)
    {
        string val_10;
        float val_13 = positionInWorldToSpawn.z;
        float val_12 = positionInWorldToSpawn.y;
        float val_11 = positionInWorldToSpawn.x;
        Unknown val_10 = this.ParticleEffectSpawnOffsets;
        if(this.CurrentParticleEffectIndex < this.ParticleEffectSpawnOffsets.Length)
        {
                val_10 = val_10 + (this.CurrentParticleEffectIndex * 12);
            val_11 = val_11 + ((this.CurrentParticleEffectIndex * 12) + this.ParticleEffectSpawnOffsets + 32);
            val_12 = val_12 + ((this.CurrentParticleEffectIndex * 12) + this.ParticleEffectSpawnOffsets + 32 + 4);
            val_13 = val_13 + ((this.CurrentParticleEffectIndex * 12) + this.ParticleEffectSpawnOffsets + 40);
            this.spawnPosition = val_11;
            mem[1152921504930430484] = val_12;
            mem[1152921504930430488] = val_13;
            if(this.CurrentParticleEffectIndex < this.ParticleEffectPrefabs.Length)
        {
                UnityEngine.GameObject val_14 = this.ParticleEffectPrefabs[this.CurrentParticleEffectIndex];
            UnityEngine.Quaternion val_2 = val_14.transform.rotation;
            Unknown val_3 = UnityEngine.Object.Instantiate<System.Object>(original:  val_14, position:  new UnityEngine.Vector3() {x = val_11, y = val_12, z = val_13}, rotation:  new UnityEngine.Quaternion() {x = val_2.x, y = val_2.y, z = val_2.z, w = val_2.w});
            if(this.CurrentParticleEffectIndex < this.ParticleEffectPrefabs.Length)
        {
                UnityEngine.GameObject val_15 = this.ParticleEffectPrefabs[this.CurrentParticleEffectIndex];
            if(val_15 != null)
        {
                val_10 = val_15;
        }
        else
        {
                val_10 = 0;
        }
        
            val_3.name = -1610604655(-1610604655) + val_10;
            Unknown val_17 = this.ParticleEffectLifetimes.Length;
            if(this.CurrentParticleEffectIndex < val_17)
        {
                if(this.ParticleEffectLifetimes[this.CurrentParticleEffectIndex] == 0f)
        {
                val_17 = val_17 + 1;
            mem2[0] = val_17;
            if(val_17 < this.ParticleEffectLifetimes[this.CurrentParticleEffectIndex].Length)
        {
                mem2[0] = val_17 + 1;
            this.ParticleEffectLifetimes[this.CurrentParticleEffectIndex][((this.ParticleEffectLifetimes.Length + 1)) << 3] = val_3.transform;
        }
        
        }
        
            val_17 = val_17 + 1;
            mem2[0] = val_17;
            if(val_17 < (mem[3221291023] + 192 + 88 + 8 + 24))
        {
                var val_9 = (mem[3221291023] + 192 + 88 + 8) + ((((this.ParticleEffectLifetimes.Length + 1) + 1)) << 3);
            mem2[0] = val_17 + 1;
            mem2[0] = val_3.transform;
        }
        
            if(this.CurrentParticleEffectIndex < this.ParticleEffectLifetimes.Length)
        {
                float val_18 = this.ParticleEffectLifetimes[this.CurrentParticleEffectIndex];
            if(val_18 == 0f)
        {
                return;
        }
        
            UnityEngine.Object.Destroy(obj:  val_3, t:  val_18);
            return;
        }
        
        }
        
        }
        
        }
        
        }
    
    }
    public ParticleEffectsLibrary()
    {
        this.effectNameString = -1610612735;
        this.spawnPosition = mem[536895737];
        mem[1152921504930430488] = mem[536895737] + 8;
    }

}
